#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/control/expr_if.hpp>

#define SCAST static_cast

#define ARGV\
        (const sc_event&)\
        (sc_event_or_list&)\
        (sc_event_and_list&)

#define LOCAL_time_if(b,formal)\
        BOOST_PP_EXPR_IF(b,BOOST_PP_EXPR_IF(formal,const sc_time&) t) BOOST_PP_COMMA_IF(b)

#define LOCAL_iter(r,has_time,type)\
void sc_log::next_trigger(LOCAL_time_if(has_time,1) type e ){                                                                                       \
        if(m_process->proc_kind()  == SC_METHOD_PROC_) {                                                                                            \
                m_log.push_back(&boost::bind(SCAST<void (sc_method_process::*)(LOCAL_time_if(has_time,1) type e )>(&sc_method_process::next_trigger)\
                                                                                  , SCAST<sc_method_process*>(m_process)                            \
                                                                                  , LOCAL_time_if(has_time,0)                                       \
                                                                                  boost::ref(e)                                                     \
                ));                                                                                                                                 \
        } else SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        ""in SC_THREADs and SC_CTHREADs use wait() instead" );                  \
}

BOOST_PP_SEQ_FOR_EACH(LOCAL_iter,0, ARGV)
BOOST_PP_SEQ_FOR_EACH(LOCAL_iter,1, ARGV)

#undef LOCAL_iter
#undef LOCAL_comma_time_if
#undef ARGV
